import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
// import app from './modules/app'
// import settings from './modules/settings'
// import user from './modules/user'

Vue.use(Vuex)

const req = require.context('./modules', false, /\.js$/)
const mName = req.keys().map(item => item.split('./')[1]).map(item => item.split('.js')[0])
const mMoudule = req.keys().map(req)

const obj = {}
mName.forEach((item, index) => {
  obj[item] = mMoudule[index].default
})

// 总仓库
const store = new Vuex.Store({
  modules: obj,
  getters
})

export default store
